FROM golang:latest AS builder
WORKDIR /src
COPY ["src", "./"]
RUN go get github.com/athurg/go-qcloud-cns-sdk
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /build/ddns-linux-amd64 ddns.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -o /build/ddns-linux-386 ddns.go
RUN CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o /build/ddns-windows-amd64.exe ddns.go
RUN CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -o /build/ddns-windows-386.exe ddns.go

FROM golang:1.10 AS builder-xp
WORKDIR /src
COPY ["src", "./"]
RUN go get github.com/athurg/go-qcloud-cns-sdk
RUN CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -o /build/ddns-winxp.exe ddns.go

FROM hamflx/alpine
WORKDIR /ddns
COPY --from=builder ["/build/*", "./"]
COPY --from=builder-xp ["/build/*", "./"]
ENTRYPOINT ["./ddns-linux-amd64"]
